package com.ejuornal.action.interceptor;


import com.ejuornal.bean.UserExt;
import com.ejuornal.service.UserExtService;
import com.ejuornal.springutil.SpringUtil;
import com.ejuornal.util.Constants;
import com.ejuornal.util.SessionUtils;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;

public class FunctionAccess implements Interceptor {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public void destroy() {
		// TODO Auto-generated method stub

	}

	@Override
	public void init() {
		// TODO Auto-generated method stub

	}

	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		// TODO Auto-generated method stub
		UserExtService uExtService = (UserExtService) SpringUtil.getBean("userExtService");
		int userId = (Integer) SessionUtils.getSession().getAttribute(Constants.USERSSSIONID);
		UserExt userExt = uExtService.findByUserId(userId);
		String result = null;
		boolean penName = (userExt.getPenName()==null)?true:false;
		boolean phone  = (userExt.getTel()==null)?true:false;
		if(penName||phone){  //信息没有完善（真实姓名、电话号码）
			return   "perfectinfo";
		}else {//完善
			result = invocation.invoke();
			return result;
		}
		
	}

}
